import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/widgets/menu_block.dart";
import "package:ct_pa_majordomo/widgets/normal_scaffold/index.dart";
import 'package:flutter/material.dart';

class OnlinePayRecordDetailPage extends StatelessWidget {
  final Map<String, dynamic> record;
  const OnlinePayRecordDetailPage({Key? key, required this.record}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final isIncome = (record["amount"] ?? 0) > 0;
    return NormalScaffold(
      title: "账单详情",
      child: Column(
        children: [
          Container(
            width: double.infinity,
            color: Colors.white,
            padding: const EdgeInsets.symmetric(vertical: 32),
            child: Column(
              children: [
                Text(
                  isIncome
                      ? "+${record["amount"].toStringAsFixed(2)}"
                      : record["amount"].toStringAsFixed(2),
                  style: TextStyle(
                    color: isIncome ? Colors.green : Colors.red,
                    fontSize: 36,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
          const SizedBox(height: 16),
          MenuBlock(
            items: [
              _buildRow("费用名称", record["type"] ?? "-"),
              _buildRow("付款人", record["payer"] ?? "-"),
              _buildRow("房源地址", record["room"] ?? "-"),
              _buildRow("交易时间", record["dateTime"] ?? record["date"] ?? "-"),
              _buildRow("支付", record["payType"] ?? "线上"),
              _buildRow("分组", record["group"] ?? "分组一"),
              _buildRow("交易单号", record["orderId"] ?? "-"),
            ],
          ),
        ],
      ),
    );
  }

  MenuBlockItem _buildRow(String label, String value) {
    return MenuBlockItem(
      text: label,
      suffix: Text(value, style: const TextStyle(color: ThemeVars.colorTextTer)),
      showArrow: false,
    );
  }
} 